<?php

namespace app\admin\model;

use think\model\Relation;

class Link extends Relation {

        protected function _after_select(&$resultSet, $options = array()) {
                parent::_after_select($resultSet, $options);
                foreach ($resultSet as $key => $value) {
                        $zone = M("Zone")->field("id,name")->where(array("id" => $value['zone']))->find();
                        $resultSet[$key]['zonename'] = $zone['name'];
                }
        }

        protected function _after_find(&$result, $options = array()) {
                parent::_after_find($result, $options);
                $zone = M("Zone")->field("id,name")->where(array("id" => $result['zone']))->find();
                $result['zonename'] = $zone['name'];
        }

}
